{extend name='admin@public/content'}
{block name="content"}
<form autocomplete="off" class="layui-form layui-box modal-form-box" style="width: 80%;" action="{:request()->url()}" data-auto="true" method="post">


    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
            <input  title="必须填写手机号"  required="required" name="phone" value='{$vo.phone|default=""}' placeholder="必填" class="layui-input">
        </div>
    </div>

<!--    {if condition="empty($type)"}-->
    <div class="layui-form-item">
        <label class="layui-form-label">登录密码</label>
        <div class="layui-input-block">
            <input  title="登录密码"  required="required" name="password" value='' placeholder="登录密码" class="layui-input">
        </div>
    </div>
<!--    {/if}-->

    <div class="layui-form-item">
        <label class="layui-form-label">真实姓名</label>
        <div class="layui-input-block">
                <input   title="必须填写真实姓名"  required="required" name="name" value='{$vo.name|default=""}' placeholder="必填" class="layui-input">
        </div>
    </div>




    <div class="layui-form-item">
        <label class="layui-form-label">厂家图片</label>
        <div class="layui-input-block">
            <div class='col-sm-8'>
                <img data-tips-image class='col-sm-8' src="{$vo.shop_img|default=''}"/>
                <input type="hidden" name="shop_img"  onchange="$(this).prev('img').attr('src', this.value)"
                       value="{$vo.shop_img|default=''}" class="layui-input">
                <a class="btn btn-info" style="float: right" data-file="one" data-field="shop_img ">上传图片</a>
                <p>建议上传尺寸为500x300px</p>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">厂家名称</label>
        <div class="layui-input-block">
            <input   title="必须填写厂家名称"  required="required" name="shop_name" value='{$vo.shop_name|default=""}' placeholder="必填" class="layui-input">
        </div>
    </div>

<div class="layui-form-item">
        <label class="layui-form-label form-require">归属区域：</label>

        <div class="layui-col-sm2 layer-midd-left">
            <select id="provinceid" name="province"  lay-verify="required" onchange="sheng()" style="display: block" class="layui-input">
                <option value="">全部</option>
                {foreach $areaList as $val}
                {if !empty($vo)}
                    {if $val['id'] == $vo['province']}
                    <option value="{$val['id']}" selected = "selected">{$val['area_name']}</option>
                    {else/}
                    <option value="{$val['id']}">{$val['area_name']}</option>
                    {/if}
                {else/}
                <option value="{$val['id']}">{$val['area_name']}</option>
                {/if}
                {/foreach}

            </select>
        </div>

        <div class="layui-col-sm2 layer-midd-left">
            <select id="cityid" name="city" lay-verify="required" onchange="xian()" style="display: block" class="layui-input">
                <option value="">全部</option>
                {if !empty($areaifno)}
                {foreach $areaifno as $c}
                {if !empty($vo['province'])}
                    {if $c['area_parent_id'] == $vo['province']}
                        {if $c['id'] == $vo['city']}
                        <option value="{$c['id']}" selected = "selected">{$c['area_name']}</option>
                        {else/}
                        <option value="{$c['id']}">{$c['area_name']}</option>
                        {/if}
                    {/if}
                {/if}
                {/foreach}
                {/if}
            </select>
        </div>

        <div class="layui-col-sm2 layer-midd-left">
            <select id="districtid" name="area" lay-verify="required" style="display: block" class="layui-input">
                <option value="">全部</option>
                {if !empty($areaifno)}
                {foreach $areaifno as $a}
                {if !empty($vo['city'])}
                    {if $a['area_parent_id'] == $vo['city']}
                        {if $a['id'] == $vo['area']}
                        <option value="{$a['id']}" selected = "selected">{$a['area_name']}</option>
                        {else/}
                        <option value="{$a['id']}">{$a['area_name']}</option>
                        {/if}
                    {/if}
                {/if}
                {/foreach}
                {/if}
            </select>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">所在纬度</label>
        <div class="layui-input-block">
            <input  title="必须所在纬度" name="lat" value='{$vo.lat|default=""}' placeholder="必填·" required="required" class="layui-input">
            <a href='https://lbs.qq.com/tool/getpoint/index.html'target="_blank" style="float: right;">前往选取位置</a>
            <div style="display:block;clear:both;"></div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">所在经度</label>
        <div class="layui-input-block">
            <input  title="必须所在经度" name="lng" value='{$vo.lng|default=""}' placeholder="必填·" required="required" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">详细位置</label>
        <div class="layui-input-block">
            <input  title="必须填写公司位置" name="address" value='{$vo.address|default=""}' placeholder="必填·" required="required" class="layui-input">
            <div style="display:block;clear:both;"></div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">标语</label>
        <div class="layui-input-block">
            <input   title="必须填写厂家标语"  required="required" name="remark" value='{$vo.remark|default=""}' placeholder="必填" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">内容<br /> <br />图片宽度限制320px</label>
        <div class="layui-input-block">
         
            <textarea name="content">{$vo.content|default=''}</textarea>
            <script>
                require(['ckeditor'], function () {
                    var editor = window.createEditor('[name="content"]');
                });
            </script>
        </div>
    </div>

    <div class="hr-line-dashed"></div>

    <div class="layui-form-item text-center">
        {if isset($vo['id'])}<input type='hidden' value='{$vo.id}' name='id'>{/if}
        <input type="hidden" value="{$admininfo}" name="admininfo" >
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>

</form>
<script>
    function  sheng() {
        var provinceid = $("#provinceid").val();
        $.ajax({
            url: "{:url('member/cityList')}",
            type: 'post',
            dataType: 'json',
            data: {provinceid:provinceid},
            success: function (res) {
                var data = res.data;
                $("#cityid").html('<option value="">全部</option>');
                $("#districtid").html('');
                if (res.code === 200) {
                    for (i=0;i<data.length;i++){
                        var html = '<option value="'+data[i].id+'">'+data[i].area_name+'</option>';
                        $("#cityid").append(html);
                    }
                } else {
                    layer.msg('添加失败', {icon: 2});
                }
            }
        });
        //alert(provinceid);
    }

    function  xian() {
        var cityid = $("#cityid").val();
        $.ajax({
            url: "{:url('member/districtList')}",
            type: 'post',
            dataType: 'json',
            data: {cityid:cityid},
            success: function (res) {
                var data = res.data;
                $("#districtid").html('<option value="">全部</option>');
                if (res.code === 200) {
                    for (i=0;i<data.length;i++){
                        var html = '<option value="'+data[i].id+'">'+data[i].area_name+'</option>';
                        $("#districtid").append(html);
                    }
                } else {
                    layer.msg('添加失败', {icon: 2});
                }
            }
        });
        //alert(provinceid);
    }

</script>
{/block}